package DesignPatterm.DependenceInversionPrinciple.improve;

/**
 * 依赖倒置原则
 */
public class DependecyInversion {
    public static void main(String[] args) {
        IReceiver iReceiver = new Email();
        iReceiver.getInfo();

    }
}

//定义一个接口
interface IReceiver {
    String getInfo();
}

//增加微信
class WeiXin implements IReceiver {

    public String getInfo() {
        return "微信信息";
    }
}

class Email implements IReceiver {

    public String getInfo() {
        return "邮件信息:hello world";
    }
}

class Person {
    public void receive(IReceiver iReceiver) {
        System.out.println(iReceiver.getInfo());
    }
}